using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.resource
{
[System.Serializable]
public  class Mine : Model
 {



    public const int TYPE_ID = 110142025;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(8);
        os.WriteSize(Tag.STRING | (1 << Tag.TAG_SHIFT));  os.WriteString(name);  
         os.WriteSize(Tag.STRING | (2 << Tag.TAG_SHIFT));  os.WriteString(decs);  
         os.WriteSize(Tag.FLOAT | (3 << Tag.TAG_SHIFT));  os.WriteFloat(scale);  
         os.WriteSize(Tag.STRING | (4 << Tag.TAG_SHIFT));  os.WriteString(path);  
         os.WriteSize(Tag.STRING | (5 << Tag.TAG_SHIFT));  os.WriteString(texture);  
         os.WriteSize(Tag.FLOAT | (6 << Tag.TAG_SHIFT));  os.WriteFloat(collisionRadius);  
         os.WriteSize(Tag.FLOAT | (7 << Tag.TAG_SHIFT));  os.WriteFloat(collisionHeight);  
         os.WriteSize(Tag.FLOAT | (8 << Tag.TAG_SHIFT));  os.WriteFloat(nameHeight);  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.STRING | (1 << Tag.TAG_SHIFT)):   name = os.ReadString(); break;  
             case (Tag.STRING | (2 << Tag.TAG_SHIFT)):   decs = os.ReadString(); break;  
             case (Tag.FLOAT | (3 << Tag.TAG_SHIFT)):   scale = os.ReadFloat(); break;  
             case (Tag.STRING | (4 << Tag.TAG_SHIFT)):   path = os.ReadString(); break;  
             case (Tag.STRING | (5 << Tag.TAG_SHIFT)):   texture = os.ReadString(); break;  
             case (Tag.FLOAT | (6 << Tag.TAG_SHIFT)):   collisionRadius = os.ReadFloat(); break;  
             case (Tag.FLOAT | (7 << Tag.TAG_SHIFT)):   collisionHeight = os.ReadFloat(); break;  
             case (Tag.FLOAT | (8 << Tag.TAG_SHIFT)):   nameHeight = os.ReadFloat(); break;  
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "Mine");
        ele.WriteStartElement("name"); ele.WriteAttributeString("id", "1"); ele.WriteString2(name); ele.WriteEndElement();
         ele.WriteStartElement("decs"); ele.WriteAttributeString("id", "2"); ele.WriteString2(decs); ele.WriteEndElement();
         ele.WriteStartElement("scale"); ele.WriteAttributeString("id", "3"); ele.WriteFloat(scale); ele.WriteEndElement();
         ele.WriteStartElement("path"); ele.WriteAttributeString("id", "4"); ele.WriteString2(path); ele.WriteEndElement();
         ele.WriteStartElement("texture"); ele.WriteAttributeString("id", "5"); ele.WriteString2(texture); ele.WriteEndElement();
         ele.WriteStartElement("collisionRadius"); ele.WriteAttributeString("id", "6"); ele.WriteFloat(collisionRadius); ele.WriteEndElement();
         ele.WriteStartElement("collisionHeight"); ele.WriteAttributeString("id", "7"); ele.WriteFloat(collisionHeight); ele.WriteEndElement();
         ele.WriteStartElement("nameHeight"); ele.WriteAttributeString("id", "8"); ele.WriteFloat(nameHeight); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  name = ele.ReadString2(); break; 
                 case 2:  decs = ele.ReadString2(); break; 
                 case 3:  scale = ele.ReadFloat(); break; 
                 case 4:  path = ele.ReadString2(); break; 
                 case 5:  texture = ele.ReadString2(); break; 
                 case 6:  collisionRadius = ele.ReadFloat(); break; 
                 case 7:  collisionHeight = ele.ReadFloat(); break; 
                 case 8:  nameHeight = ele.ReadFloat(); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "name":  name = ele.ReadString2(); break; 
                 case "decs":  decs = ele.ReadString2(); break; 
                 case "scale":  scale = ele.ReadFloat(); break; 
                 case "path":  path = ele.ReadString2(); break; 
                 case "texture":  texture = ele.ReadString2(); break; 
                 case "collision_radius":  collisionRadius = ele.ReadFloat(); break; 
                 case "collision_height":  collisionHeight = ele.ReadFloat(); break; 
                 case "name_height":  nameHeight = ele.ReadFloat(); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
